package com.cherrish.demo.algorithm.sort;

/**
 * @author cherrish
 * @time 2019-02-22 15:19
 * @name SortHell
 * @desc:
 */
public class SortHell implements ISort{
    @Override
    public void sort(int[] arr, int len) {
        int h = 1;
        while (h < len/3){
            h = 3 * h + 1;
        }
        for(;h >= 1; h/=3){
            for(int i = 0; i < len - h; i += h){
                for(int j = i + h; j > 0; j -= h){
                    if(arr[j] < arr[j - h]){
                        swap1(arr, j, j - h);
                    }
                }
            }
        }
    }
}
